/* 可视化编辑器样式 */
.visual-editor-container {
  width: 100%;
  height: 100%;
  min-height: 200px;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 编辑器工具栏 */
.visual-editor-toolbar {
  padding: 8px 16px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #495057;
}

.toolbar-label {
  font-weight: 500;
}

/* 编辑器主体 */
.visual-editor {
  flex: 1;
  padding: 20px;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  overflow-y: auto;
  min-height: 200px;
}

/* 占位符样式 */
.visual-editor[placeholder]:empty:before {
  content: attr(placeholder);
  color: #999;
  pointer-events: none;
  font-style: italic;
}

/* 数学公式样式 */
.math-element {
  position: relative;
  transition: all 0.2s ease;
}

/* 行内公式 */
.inline-math {
  display: inline-block;
  vertical-align: middle;
  margin: 0 2px;
  background-color: rgba(240, 240, 240, 0.5);
  padding: 2px 6px;
  border-radius: 3px;
}

/* 块级公式 */
.block-math {
  display: block;
  margin: 16px 0;
  padding: 12px 20px;
  background-color: #f8f9fa;
  border-left: 3px solid #1976d2;
  border-radius: 4px;
  text-align: center;
}

/* 公式错误状态 */
.math-error {
  background-color: #f8d7da !important;
  border-color: #dc3545 !important;
  color: #721c24;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  padding: 8px;
  border-radius: 3px;
}

/* 数学文本 */
.math-text {
  font-family: 'Cambria Math', 'Times New Roman', serif;
}

/* 选中状态 */
.math-element.selected {
  background-color: rgba(25, 118, 210, 0.1);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* KaTeX 渲染样式调整 */
:global(.katex) {
  font-size: 1.1em !important;
}

:global(.katex-display) {
  margin: 0.5em 0 !important;
}

/* 编辑器中段落样式 */
.visual-editor p {
  margin: 0 0 16px 0;
  padding: 0;
}

.visual-editor p:last-child {
  margin-bottom: 0;
}

/* 滚动条样式 */
.visual-editor::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.visual-editor::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.visual-editor::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.visual-editor::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 拖拽调整大小 */
.resize-handle {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  cursor: se-resize;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 4V0H12V4H8ZM0 8H4V12H0V8Z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.math-element:hover .resize-handle {
  opacity: 1;
}

/* 编辑器焦点状态 */
.visual-editor:focus-within {
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .visual-editor {
    padding: 16px;
    font-size: 14px;
    min-height: 150px;
  }
  
  .block-math {
    margin: 12px 0;
    padding: 10px 16px;
  }
  
  :global(.katex) {
    font-size: 1.05em !important;
  }
}

/* 无障碍支持 */
.visual-editor {
  aria-label: "可视化公式编辑区";
}

/* 打印样式 */
@media print {
  .visual-editor-container {
    border: none !important;
  }
  
  .visual-editor-toolbar {
    display: none !important;
  }
  
  .inline-math,
  .block-math {
    background: none !important;
    border: none !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .visual-editor-container {
    border: 2px solid #000;
  }
  
  .inline-math,
  .block-math {
    border: 1px solid #000;
  }
}